<template>
    <div v-if="detailsVisible" style="display: flex;">
        <div class="rightitem">
            <el-row style="margin: 10px 20px 10px 10px;">
                <el-select v-model="activeIndex" clearable placeholder="请选择" @change="changetype">
                    <el-option label='入党积极分子' value='入党积极分子'></el-option>
                    <el-option label='重点培养对象' value='重点培养对象'></el-option>
                    <el-option label='预备党员' value='预备党员'></el-option>
                    <el-option label='党员' value='党员'></el-option>
                </el-select>
                <el-button  size="mini"    @click="serchfile" style="position: absolute;right: 0px;">查询</el-button>
            </el-row>
            <el-table :data="recoderfilesTrue"  border  :empty-text="showemptytext" >
                <el-table-column type="index" label="序号"  align="center" width="40" :index="indexbf"></el-table-column>
                <el-table-column prop="truename" type="text" label="姓名" width="100" align="center" ></el-table-column>
                <template v-if="showdwname==true">
                    <el-table-column prop="dwname" type="text" label="党委" width="180" align="center" :show-overflow-tooltip='true'></el-table-column>
                </template>
                <template v-if="showdzbname==true">
                    <el-table-column prop="dzbname" type="text" label="党支部" width="180" align="center" :show-overflow-tooltip='true'></el-table-column>
                </template>
                <el-table-column type="text" label="入党意愿时间" width="120" align="center" >
                    <template slot-scope="scope" >
                        <div v-if="scope.row.datea==''"><a target="_blank" >无</a></div>
                        <div v-if="scope.row.datea!=''"><a target="_blank" >{{scope.row.datea}}</a></div>
                    </template> 
                </el-table-column>
                <el-table-column type="text" label="入党积极分子时间" width="160" align="center" >
                    <template slot-scope="scope" >
                        <div v-if="scope.row.dateb==''"><a target="_blank" >无</a></div>
                        <div v-if="scope.row.dateb!=''"><a target="_blank" >{{scope.row.dateb}}</a></div>
                    </template>
                </el-table-column>
                <el-table-column type="text" label="重点培养对象时间" width="160" align="center" >
                    <template slot-scope="scope" >
                        <div v-if="scope.row.datec==''"><a target="_blank" >无</a></div>
                        <div v-if="scope.row.datec!=''"><a target="_blank" >{{scope.row.datec}}</a></div>
                    </template>
                </el-table-column>
                <el-table-column type="text" label="预备党员时间" width="120" align="center" >
                    <template slot-scope="scope" >
                        <div v-if="scope.row.dated==''"><a target="_blank" >无</a></div>
                        <div v-if="scope.row.dated!=''"><a target="_blank" >{{scope.row.dated}}</a></div>
                    </template>
                </el-table-column>
                <el-table-column type="text" label="正式党员时间" width="120" align="center" >
                    <template slot-scope="scope" >
                        <div v-if="scope.row.datee==''"><a target="_blank" >无</a></div>
                        <div v-if="scope.row.datee!=''"><a target="_blank" >{{scope.row.datee}}</a></div>
                    </template>
                </el-table-column>
                <el-table-column  width="125" label="入党志愿书序号" :show-overflow-tooltip='true' align="center">
                    <template slot-scope="scope" >
                        <div v-if="scope.row.zysid==''"><a target="_blank" >无</a></div>
                        <div v-if="scope.row.zysid!=''"><a target="_blank" >{{scope.row.zysid}}</a></div>
                    </template>
                </el-table-column>
                <el-table-column  width="125" label="入党志愿书" :show-overflow-tooltip='true' align="center">
                    <template slot-scope="scope" >
                        <div v-if="scope.row.content==''"><a target="_blank" >无</a></div>
                        <div v-if="scope.row.content!=''"><a target="_blank" :href="scope.row.content">点击查看</a></div>
                    </template> 
                </el-table-column>
                <el-table-column prop="store" width="165" label="志愿书存放" :show-overflow-tooltip='true' align="center">
                    <template slot-scope="scope" >
                        <div v-if="scope.row.store==''"><a target="_blank" >无</a></div>
                        <div v-if="scope.row.store!=''"><a target="_blank" >{{scope.row.store}}</a></div>
                    </template> 
                </el-table-column>
                <el-table-column  width="125" label="思想汇报" :show-overflow-tooltip='true' align="center">
                    <template slot-scope="scope">
                        <el-button  type="text" @click="showsxhb(scope.row)">查看思想汇报</el-button>
                    </template> 
                </el-table-column>
                <el-table-column align="right">
                    <!-- <template slot="header" slot-scope="scope">
                        <el-button  size="mini"    @click="serchfile">查询</el-button>
                    </template> -->
                    <template slot-scope="scope">
                        <el-dropdown trigger="click" @command="fileCommand" v-if="showAddF==true">
                            <span class="el-dropdown-link">操作<i class="el-icon-caret-bottom el-icon--right"></i></span>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item class="clearfix" :command="{data:scope.row,typed:'editime'}">编辑时间</el-dropdown-item>
                                <el-dropdown-item class="clearfix" :command="{data:scope.row,typed:'zhuanzheng'}">编辑党员类型</el-dropdown-item>
                                <el-dropdown-item class="clearfix" :command="{data:scope.row,typed:'editzys'}">编辑志愿书</el-dropdown-item>
                                <!-- <el-dropdown-item class="clearfix" :command="{data:scope.row,typed:'editsxhb'}">编辑思想汇报</el-dropdown-item> -->
                            </el-dropdown-menu>
                        </el-dropdown>
                    </template>
                </el-table-column>
            </el-table>
            <pagination @changed="showDataTrue" :recoder="recoderfiles"> </pagination>
        </div>
        <editime ref='editime' v-on:editResult="serchfile"></editime>
        <zhuanzheng ref='zhuanzheng' v-on:editResult="serchfile"></zhuanzheng>
        <editzys ref='editzys' v-on:editResult="serchfile"></editzys>
        <sxhb ref='sxhb' v-on:editResult="serchfile"></sxhb>
    </div>
</template>
<script>
    import {mapActions} from 'vuex';
    export default {
        data: () => ({
            detailsVisible:true,

            showAddF:false,//显示添加的按钮,  //只有党支部才可以显示添加
            showdwname:false,
            showdzbname:false,
            activeIndex:'入党积极分子',
            //第二个表格
            recoderfiles:[], //获取到的文件
            recoderfilesTrue:[],//真正在表格里面显示的 由于分页等原因
            // 表格分页
            offset:0, //分页的offset
            showdwdzb:false,


            default_emptytext:"请左侧 类型 选择 并查询",
            showemptytext:'',
            //如果需要新增  请在人员管理中添加
        }),
        mounted() {
            if(this.GetUser()==false){
                this.$router.push("/");
            }
            this.GetActiveDwId_DzbId();
            if(this.$store.state.Dw_DzbID.dwid==-1){
                this.showdwname=true ;this.showdzbname=false ;
            }
            else if(this.$store.state.Dw_DzbID.dwid>0 &&this.$store.state.Dw_DzbID.dzbid==-1){
                this.showdwname=false ;this.showdzbname=true ;
            }
            else{
                this.showdwname=false ;this.showdzbname=false ;
                
            }
            if (this.$store.state.user.operation <= 2 && this.$store.state.Dw_DzbID.dzbid>0) 
            {
                this.showAddF = true;
            }
        },
        watch: {},
        components: {
            editime: function(resolve) {require(["./editime.vue"], resolve);},
            zhuanzheng: function(resolve) {require(["./zhuanzheng.vue"], resolve);},
            editzys: function(resolve) {require(["./editzys.vue"], resolve);},
            sxhb: function(resolve) {require(["./sxhb.vue"], resolve);},
        },
        methods: {
            ...mapActions(['GetUser','GetZbById','GetActiveDwId_DzbId']),
            changetype(type){
                this.serchfile();
            },
            showallFiledsF(){
                this.showallFileds=!this.showallFileds;
            },
            serchfile(){
                this.recoderfiles=[];let _this=this;
                let postdata={
                    type:"serchdyfz",
                    split:JSON.stringify({
                        dwid:this.$store.state.Dw_DzbID.dwid,
                        dzbid:this.$store.state.Dw_DzbID.dzbid,
                        type:this.activeIndex
                    })
                }
                this.$Common.AjaxPost(postdata,true)
                .then(function(e){
                    if(e.length==0){
                        _this.showemptytext='没有找到记录';
                        setTimeout(() => {
                            _this.showemptytext=_this.default_emptytext;
                        }, 1000);
                    }
                    else{
                        _this.recoderfiles=e;
                    }
                }).catch(function(reason) {
                    console.log('catch:', reason);
                });
            },
            showDataTrue(showrecoders,offset){
                this.recoderfilesTrue=showrecoders;
                this.offset=offset;
            },
            indexbf(index){return index+this.offset+1;},
            fileCommand(value){
                let row=value.data;
                let typed=value.typed;
                let _this=this;
                if(typed=="editime"){
                    this.$refs.editime.$data.dialogVisible = true;
                    this.$refs.editime.$data.rowdata.truename = row.truename;
                    this.$refs.editime.$data.rowdata.personid = row.personid;
                    this.$refs.editime.$data.rowdata.datea = row.datea;
                    this.$refs.editime.$data.rowdata.dateb = row.dateb;
                    this.$refs.editime.$data.rowdata.datec = row.datec;
                    this.$refs.editime.$data.rowdata.dated = row.dated;
                    this.$refs.editime.$data.rowdata.datee = row.datee;
                }
                else if(typed=="zhuanzheng"){
                    this.$refs.zhuanzheng.$data.dialogVisible = true;
                    this.$refs.zhuanzheng.$data.rowdata.truename = row.truename;
                    this.$refs.zhuanzheng.$data.rowdata.personid = row.personid;
                    this.$refs.zhuanzheng.$data.rowdata.dateD = row.dateD;
                }
                else if(typed=="editzys"){
                    this.$refs.editzys.$data.dialogVisible = true;
                    this.$refs.editzys.$data.rowdata.truename = row.truename;
                    this.$refs.editzys.$data.rowdata.personid = row.personid;
                    this.$refs.editzys.$data.rowdata.zysid = row.zysid;
                    this.$refs.editzys.$data.rowdata.content = row.content;
                    this.$refs.editzys.$data.rowdata.store = row.store;
                }
                else if(typed=="editsxhb"){
                    // this.$refs.editzys.$data.dialogVisible = true;
                    // this.$refs.editzys.$data.rowdata.truename = row.truename;
                    // this.$refs.editzys.$data.rowdata.personid = row.personid;
                    // this.$refs.editzys.$data.rowdata.zysid = row.zysid;
                    // this.$refs.editzys.$data.rowdata.content = row.content;
                    // this.$refs.editzys.$data.rowdata.store = row.store;
                }
            },
            showsxhb(row){
                this.$refs.sxhb.$data.detailsVisible = true;
                this.$refs.sxhb.$data.showAdd = this.showAddF;
                this.$refs.sxhb.$data.personid =row.personid;
                this.$refs.sxhb.$data.truename =row.truename;
            }
        }
    }
</script>
<style>
</style>